package com.sky.controller.user;

import com.sky.constant.PasswordConstant;
import com.sky.constant.StatusConstant;
import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 山顶洞人郑某
 * @className CategoryController.java
 * @date 2024 02 07
 */
@RequestMapping("/user/category")
@RestController("userCategoryController")
@Slf4j
@Api("/C端菜品相关接口")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/list")
    @ApiOperation(value = "所有分类查询")
    public Result<List<Category>> list(Integer type){
        if (type != null) {
            log.info("查询的套餐分类为：{}", type == 1 ? "菜品分类" : "套餐分类");
        }
         List<Category> list = categoryService.list(type);
         log.info("所有套餐信息为:{}",list);
         return Result.success(list);
    }
}
